import java.util.Set;
import java.util.HashMap;
import java.util.ArrayList;
/**
 * Klassen Room - er rummene i vores spil.
 * den her klasse er en del af vores spil 
 * Class Room - a room in an adventure game.
 *
 * This class is part of the "World of Zuul" application. 
 * "World of Zuul" is a very simple, text based adventure game.  
 *
 * A "Room" represents one location in the scenery of the game.  It is 
 * connected to other rooms via exits.  The exits are labelled north, 
 * east, south, west.  For each direction, the room stores a reference
 * to the neighboring room, or null if there is no exit in that direction.
 * 
 * @author  Morten Jakob Danny
 * @version 2011.07.31
 */
public class Room 
{
    public String description;
    private HashMap<String, Room> exits; 
    private ArrayList<Item> items;
    private Game game;

    /**
     * Create a room described "description". Initially, it has
     * no exits. "description" is something like "a kitchen" or
     * "an open court yard".
     * @param description The room's description.
     */
    public Room(String description) 
    {
        this.description = description;
        exits = new HashMap<String, Room>();
        items = new ArrayList<Item>(); 
    }

    /**
     * Define the exits of this room.  Every direction either leads
     * to another room or is null (no exit there).

     */
     public void setExit(String direction, Room neighbor) 
    {
        exits.put(direction, neighbor);
    }

    /**
     * @return The description of the room.
     */
    public String getDescription()
    {
        return description;
    }
    
    /**
     * Return a description of the room in the form:
     *     You are in the kitchen.
     *     Exits: north west
     * @return A long description of this room
     */
     public String getLongDescription()
    {
        String longDesc =  "Du er " + description + ".\n" + getExitString();
        if (items.size() > 0) {
            longDesc += "\n de følgende ting du kan søge i er her:\n";
            for (Item item : items) {
                longDesc += "\n" + item.getDesc() + "\n";
            }
        }
        return longDesc;
    }
    
        /**
     * Return a string describing the room's exits, for example
     * "Exits: north west".
     * @return Details of the room's exits.
     */
    private String getExitString()
    {
        String returnString = "Udgange:";
        Set<String> keys = exits.keySet();
        for(String exit : keys) {
            returnString += " " + exit;
        }
        return returnString;
    }
  
        /**
     * Return the room that is reached if we go from this room in direction
     * "direction". If there is no room in that direction, return null.
     * @param direction The exit's direction.
     * @return The room in the given direction.
     */
    public Room getExit(String direction) 
    {
        return exits.get(direction);
    }
    
        /**
     * add an item to the room
     */
    public void addItem(Item i) {
        items.add(i);
    }
    
      /**
     * doSearch
     */
    public void doSerach(Command command) 
    {
        items.add(new Item("key", 30));
        for ( Item item : items)
        {
            if ( key = true ) {
                game.printKeyFound();
            }
            if ( key = false )
            {
                game.printKeyNotFound();   
            }

    }
   }
}

